home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / fast278j.lzh / SHOOT.F < prev    next >
Text File  |  1992-07-20  |  13KB  |  748 lines

  1. #short
  2. const bullets=10,bull_size=4,key_repeat=1,ammo=500,games=10
  3. const scaley=3,scalex=22
  4. const exps=500,exp_size=5
  5. const things=8,thing_size=5
  6. var x,y,timing,last1,last2,playing,sc1,sc2,sbx,hit1,hit2,m,bdir,am1,am2
  7. expl  ? exps*exp_size
  8. bull1 ? bullets*bull_size
  9. bull2 ? bullets*bull_size
  10.  
  11. video=0b800h
  12. mode 640,and
  13. #include keys.fi
  14. set_keys
  15.  
  16. n=timer mod 200
  17. while n x=rnd:n--
  18.  
  19. computer=0
  20. n=81h
  21. while peekb n<>13
  22.     {
  23.     if (ucase peekb n)='C' then computer=1
  24.     n++
  25.     }
  26.  
  27. proc abort reset_keys:screen 3:terminate
  28.  
  29. proc setup_screen
  30.     {
  31.     screen 6
  32.     colour 0:cls
  33.     colour 1
  34.     }
  35.  
  36. proc setup_players
  37.     {
  38.     am1=ammo:am2=ammo
  39.     x1=10:y1=(rnd mod 160)+20
  40.     x2=620:y2=(rnd mod 160)+20
  41.     fill bullets*bull_size from bull1 with 0
  42.     fillb exps*exp_size from expl with 0
  43.     }
  44.  
  45. proc move_players
  46.     {
  47.     #long
  48.     if timing and 3 then
  49.     {
  50.     #short
  51.     if key_press(60) then y1-=scaley:if y1<22 then
  52.         {
  53.         y1=22
  54. ;        sprite x1,y1,null_thing
  55. ;        y1=176
  56.         }
  57.     if key_press(62) then y1+=scaley:if y1>176 then
  58.         {
  59.         y1=176
  60. ;        sprite x1,y1,null_thing
  61. ;        y1=22
  62.         }
  63.     #long
  64.  
  65.     if computer then
  66.         {
  67.         cm=bull1
  68.         ls=y2
  69.         r=rnd
  70.         if r>-20000 then goto comp_any
  71.         repeat bullets*2
  72.         {
  73.         x=peek cm:bd=peekb (cm+3)
  74.         if (x>400) and (bd<128) then
  75.             {
  76.             #short
  77.             y=peekb (cm+2)
  78.             if y<=(y2+9) then
  79.             {
  80.             if y2>160 then y2-=scaley else y2+=scaley
  81.             }
  82.             if y>(y2+9) then
  83.             {
  84.             if y2<36 then y2+=scaley else y2-=scaley
  85.             }
  86.             #long
  87.             }
  88.         cm+=bull_size
  89.         }
  90.         comp_any:
  91.         #short
  92.         if y2>(ls+scaley) then y2=ls+scaley
  93.         if y2<(ls-scaley) then y2=ls-scaley
  94.         if ls=y2 then
  95.         {
  96.         nr=rnd
  97.         if (nr>=0) and (y1<y2) then y2-=scaley
  98.         if (nr<0) and (y1>y2) then y2+=scaley
  99.         }
  100.         #long
  101.         }
  102.     else
  103.         {
  104.         #short
  105.         if key_press(75) then y2-=scaley
  106.         if key_press(79) then y2+=scaley
  107.         #long
  108.         }
  109.     #short
  110.     if y2<22 then
  111.         {
  112.         y2=22
  113. ;        sprite x2,y2,null_thing
  114. ;        y2=176
  115.         }
  116.     if y2>176 then
  117.         {
  118.         y2=176
  119. ;        sprite x2,y2,null_thing
  120. ;        y2=22
  121.         }
  122.     #long
  123.     }
  124.     sprite x1,y1,player1
  125.     sprite x2,y2,player2
  126.     #short
  127.     }
  128.  
  129. proc print_score
  130.     {
  131.     if (last1<>sc1) or (last2<>sc2) then
  132.     {
  133.     cursor 0,2:print bios sc1;"  ";
  134.     cursor 0,73:print bios sc2;"  ";
  135.     cursor 1,3:print bios hit1;"  - ";am1;"  ";
  136.     cursor 1,67:print bios hit2;"  - ";am2;"  ";
  137.     last1=sc1:last2=sc2
  138.     }
  139.     }
  140.  
  141. proc setup_things
  142.     {
  143.     m=thingd
  144.     repeat things
  145.     {
  146.     pokeb m+3,255
  147.     nr=rnd
  148.     if nr and 2048 then
  149.         {
  150.         pokeb m,nr
  151.         pokeb m+1,(rnd mod 160)+20
  152.         pokeb m+2,100
  153.         t=rnd mod 3
  154.         pokeb m+3,t
  155.         i=40:if t=1 then i=10
  156.         if t=2 then i=20
  157.         pokeb m+4,i
  158.         }
  159.     m+=thing_size
  160.     }
  161.     }
  162.  
  163. proc crater(cx,cy,cc,cd)
  164.     {
  165.     cm=expl
  166.     repeat exps
  167.     {
  168.     #long
  169.     if cc then
  170.         {
  171.         px=peek cm
  172.         if not px then
  173.         {
  174.         #short
  175.         poke cm,cx:pokeb cm+2,cy
  176.         nr=rnd
  177.         cyi=nr and 7:if nr and 16384 then cyi=0-cyi
  178.         cxi=1+((nr and 11110000b)/16)
  179.         if cd=-1 then cxi=0-cxi
  180.         if cd=0 then if nr and 32768 then cxi=0-cxi
  181.  
  182.         pokeb cm+3,cxi
  183.         pokeb cm+4,cyi
  184.         cc--
  185.         repeat 8 noise 1,2000+(rnd and 1023)
  186.         noise off
  187.         #long
  188.         }
  189.         }
  190.     else return
  191.  
  192.     #short
  193.     cm+=exp_size
  194.     }
  195.     }
  196.  
  197. proc test_hit
  198.     {
  199.     #long
  200.     if playing then
  201.     {
  202.     if x<(x1+14) then
  203.         {
  204.         #short
  205.         if (y>y1) and (y<(y1+15)) then
  206.         {
  207.         crater(x1,y1,exps,1)
  208.         sc2+=200
  209.         hit2++
  210.         playing=0
  211.         }
  212.         #long
  213.         }
  214.     else
  215.         {
  216.         #short
  217.         if (y>y2) and (y<(y2+15)) then
  218.         {
  219.         crater(x2,y2,exps,-1)
  220.         sc1+=200
  221.         hit1++
  222.         playing=0
  223.         }
  224.         #long
  225.         }
  226.     }
  227.     #short
  228.     }
  229.  
  230. proc clear_bullet
  231.     {
  232.     sprite x,y,sp_null
  233.     x=0
  234.     }
  235.  
  236. function bullet_hit
  237.     {
  238.     tm=thingd
  239.     repeat things
  240.     {
  241.     tt=peekb (tm+3)
  242.     #long
  243.     if tt<>255 then
  244.         {
  245.         tx=peekb tm*2+64
  246.         ty=peekb (tm+1)
  247.         sa=peek (stable+tt*2)
  248.         if hit x,y,sp_bull1 with tx,ty,sa 1 then
  249.         {
  250.         #short
  251.         if tt=5 then
  252.             {
  253.             sprite x,y,sp_null
  254.             pokeb m+3,(256-bdir)
  255.             return 0
  256.             }
  257.         if tt>2 then
  258.             {
  259.             scn=2:if tt=4 then scn=5
  260.             if sbx=(x1+16) then sc1+=scn else sc2+=scn
  261.             }
  262.         n=peekb (tm+4)
  263.         n--
  264.         pokeb tm+4,n
  265.         if not n then
  266.             {
  267.             sprite tx,ty,null_thing
  268.             pokeb tm+3,255
  269.             }
  270.         return 1
  271.         #long
  272.         }
  273.         }
  274.     tm+=thing_size
  275.     #short
  276.     }
  277.     return 0
  278.     }
  279.  
  280. proc move_bullets
  281.     {
  282.     bk=41:bi=16:sbx=x1+16:sby=y1     ;bi=scalex 2?
  283.     m=bull1
  284.     repeat 2
  285.     {
  286.     fired=timing mod 5
  287.     repeat bullets
  288.         {
  289.         x=peek m
  290.         #long
  291.         if x then
  292.         {
  293.         #short
  294.         y=peekb (m+2):bdir=peekb (m+3)
  295.         if (x<(x1+14)) or (x>x2-24) then
  296.             {
  297.             test_hit
  298.             clear_bullet
  299.             goto next_bullet
  300.             }
  301.  
  302.         if bdir<16 then if rnd<-2000 then bdir++
  303.         if bdir>240 then if rnd<-2000 then bdir--
  304.         pokeb m+3,bdir
  305.  
  306.         if bdir<128
  307.             then spb=sp_bull1:x+=bdir
  308.             else x-=256-bdir:spb=sp_bull2
  309.  
  310.         sprite x,y,spb
  311.         if bullet_hit then
  312.             {
  313.             crater(x,y,40,0)
  314.             clear_bullet
  315.             goto next_bullet
  316.             }
  317.         #long
  318.         }
  319.         else
  320.         {
  321.         if playing then
  322.             {
  323.             #short
  324.             if computer and (bk=78) then
  325.             {
  326.             if (fired=0) and (rnd>27000) then goto fire_it
  327.             }
  328.             #long
  329.             if (key_press(bk)<>0) and (fired=0) then
  330.             {
  331.             fire_it:
  332.  
  333.             if bk=41 then
  334.                 {
  335.                 if am1 then
  336.                 {
  337.                 am1--
  338.                 cursor 1,3:print bios hit1;"  - ";am1;"  ";
  339.                 pokeb m+2,sby+8
  340.                 pokeb m+3,bi
  341.                 x=sbx
  342.                 fired=1
  343.                 for n=1000 to 1050:noise 2,n:next n:noise off
  344.                 }
  345.                 }
  346.             else
  347.                 {
  348.                 if am2 then
  349.                 {
  350.                 am2--
  351.                 cursor 1,67:print bios hit2;"  - ";am2;"  ";
  352.                 pokeb m+2,sby+8
  353.                 pokeb m+3,bi
  354.                 x=sbx
  355.                 fired=1
  356.                 for n=1000 to 1050:noise 2,n:next n:noise off
  357.                 }
  358.                 }
  359.             }
  360.             }
  361.         }
  362.         #short
  363.         next_bullet:
  364.         poke m,x
  365.         m+=bull_size
  366.         }
  367.     bk=78:bi=-16:sbx=x2-24:sby=y2    ;bi=-2?
  368.     }
  369.     }
  370.  
  371. proc plot_exp(c)
  372.     {
  373.     colour c
  374.     plot x-1,y
  375.     plot x+1,y
  376.     plot x,y-1
  377.     plot x,y+1
  378.     }
  379.  
  380. proc move_exp
  381.     {
  382.     m=expl
  383.     repeat exps
  384.     {
  385.     x=peek m
  386.     #long
  387.     if x then
  388.         {
  389.         #short
  390.         y=peekb (m+2)
  391.         xi=peekb (m+3):yi=peekb (m+4)
  392.         plot_exp(0)
  393.         if xi<128 then x+=xi else x-=(256-xi)
  394.         if yi<128 then y+=yi else y-=(256-yi)
  395.         if (x<1) or (x>638) or (y<21) or (y>198) then
  396.         {
  397.         x=0:goto next_exp
  398.         }
  399.  
  400.         plot_exp(1)
  401.         pokeb m+2,y
  402.         pokeb m+3,xi:pokeb m+4,yi
  403.  
  404.         next_exp:
  405.         poke m,x
  406.         #long
  407.         }
  408.     #short
  409.     m+=exp_size
  410.     }
  411.     }
  412.  
  413. proc move_things
  414.     {
  415.     m=thingd
  416.     repeat things
  417.     {
  418.     t=peekb (m+3)
  419.     #long
  420.     if t<>255 then
  421.         {
  422.         #short
  423.         y=peekb (m+1)
  424.         yi=peekb (m+2)
  425.         x=peekb m
  426.         sa=peek (stable+t*2)
  427.  
  428.         if yi<>100 then
  429.         {
  430.         iii=1:if yi>127 then iii=-1:yi=256-yi
  431.         if (timing and yi)=0 then y+=iii
  432.         if (y<20) or (y>180) then
  433.             {
  434.             sprite x*2+64,y,null_thing
  435.             pokeb m+3,255
  436.             goto next_thing
  437.             }
  438.         }
  439.  
  440.         sprite x*2+64,y,sa
  441.         pokeb m,x:pokeb m+1,y
  442.         next_thing:
  443.         #long
  444.         }
  445.     else
  446.         {
  447.         nr=rnd
  448.         if nr>31500 then
  449.         {
  450.         pokeb m,nr
  451.         nr=rnd
  452.         tt=3:iii=7:if nr and 16384 then tt=4:iii=0
  453.         if (nr and 40960)=32768 then tt=5:iii=3
  454.         y=20:yi=iii
  455.         if nr and 4096 then y=180:yi=0-iii
  456.         pokeb m+1,y:pokeb m+2,yi
  457.         pokeb m+3,tt
  458.         pokeb m+4,1
  459.         }
  460.         }
  461.     #short
  462.     m+=thing_size
  463.     }
  464.     }
  465.  
  466. proc game_it
  467.     {
  468.     timing++
  469.     print_score
  470.     move_bullets
  471.     move_exp
  472.     move_things
  473.     if not (am1 or am2) then am1=ammo:am2=ammo:last1=-1
  474.     }
  475.  
  476. ;BEGIN GAME
  477. start_game:
  478.  
  479. sc1=0:sc2=0
  480. hit1=0:hit2=0
  481.  
  482. while (hit1<games) and (hit2<games)
  483.     {
  484.     setup_screen
  485.     setup_players
  486.     playing=1
  487.     last1=-1:last2=-1
  488.     setup_things
  489.  
  490.     game_it
  491.     move_players
  492.     repeat 3
  493.     {
  494.     for m=2500 to 3800 step 8
  495.     noise 30,m
  496.     next m
  497.     }
  498.     noise off
  499.  
  500.     while playing
  501.     {
  502.     game_it
  503.     move_players
  504.     if key_press(1) then playing=0
  505.     if key_press(55) then abort
  506.     repeat 10 repeat 1000 {}
  507.     }
  508.  
  509.     repeat 160
  510.     {
  511.     repeat 300 {}
  512.     game_it
  513.     }
  514.     }
  515.  
  516. cursor 10,14
  517. repeat 52 print bios "-";
  518. cursor 11,25
  519. win=1:if hit2=games then win=2
  520. print bios "   SHOOT ->>>  Player ";chr win+'0';" wins!   ";
  521. cursor 12,14
  522. repeat 52 print bios "-";
  523.  
  524. repeat 50
  525.     {
  526.     noise 1000,(rnd and 1023)+1500
  527.     }
  528. noise off
  529. cursor 24,0:print bios "Another go?  ";
  530.  
  531. wait_proper:
  532. k=ucase key
  533. if k='Y' then goto start_game
  534. if (k<>'N') and (k<>27) then goto wait_proper
  535. print bios "Wrong!";:beep
  536. abort
  537.  
  538. thingd:
  539. space things*thing_size
  540.  
  541. player1:
  542. datab 1,22
  543. shape "                "
  544. shape "                "
  545. shape "                "
  546. shape "**              "
  547. shape "***             "
  548. shape "****            "
  549. shape "*****           "
  550. shape "*******         "
  551. shape "*********       "
  552. shape "**********      "
  553. shape "*************** "
  554. shape "*************** "
  555. shape "**********      "
  556. shape "*********       "
  557. shape "*******         "
  558. shape "*****           "
  559. shape "****            "
  560. shape "***             "
  561. shape "**              "
  562. shape "                "
  563. shape "                "
  564. shape "                "
  565.  
  566. player2:
  567. datab 1,22
  568. shape "                "
  569. shape "                "
  570. shape "                "
  571. shape "              **"
  572. shape "             ***"
  573. shape "            ****"
  574. shape "           *****"
  575. shape "         *******"
  576. shape "       *********"
  577. shape "      **********"
  578. shape " ***************"
  579. shape " ***************"
  580. shape "      **********"
  581. shape "       *********"
  582. shape "         *******"
  583. shape "           *****"
  584. shape "            ****"
  585. shape "             ***"
  586. shape "              **"
  587. shape "                "
  588. shape "                "
  589. shape "                "
  590.  
  591. sp_bull1:
  592. datab 3,4
  593. data 0
  594. shape "                  *******       "
  595. data 0
  596. shape "                ****************"
  597. data 0
  598. shape "                ****************"
  599. data 0
  600. shape "                  *******       "
  601.  
  602. sp_bull2:
  603. datab 3,4
  604. shape "       *******                  "
  605. data 0
  606. shape "****************                "
  607. data 0
  608. shape "****************                "
  609. data 0
  610. shape "       *******                  "
  611. data 0
  612.  
  613. sp_null:
  614. datab 3,4
  615. data 0,0,0
  616. data 0,0,0
  617. data 0,0,0
  618. data 0,0,0
  619. data 0,0,0
  620.  
  621. stable:
  622. data swall,stree,srock,sperson,scar,smirror
  623.  
  624. swall:
  625. datab 1,20
  626. shape "********        "
  627. shape "***    **       "
  628. shape "****    **      "
  629. shape "** **    **     "
  630. shape "**  **    **    "
  631. shape "**   **    **   "
  632. shape "***   **    **  "
  633. shape "** *   **    ** "
  634. shape "**  *   ********"
  635. shape "***  *  **    **"
  636. shape "** *  * **    **"
  637. shape "**  *  ***    **"
  638. shape " **  *  **    **"
  639. shape "  **  * **    **"
  640. shape "   **  ***    **"
  641. shape "    **  **    **"
  642. shape "     ** **    **"
  643. shape "      ****    **"
  644. shape "       ***    **"
  645. shape "        ********"
  646.  
  647. stree:
  648. datab 1,14
  649. shape "    ** *******  "
  650. shape "  *** *     * * "
  651. shape "   * * **  *   *"
  652. shape "  * *    *     *"
  653. shape "   **   *    ** "
  654. shape "    *** **  *   "
  655. shape "     **   **    "
  656. shape "      ****      "
  657. shape "      ***       "
  658. shape "      ***       "
  659. shape "      ***       "
  660. shape "      ***       "
  661. shape "     ****       "
  662. shape "     *****      "
  663.  
  664. srock:
  665. datab 1,11
  666. shape "      *****     "
  667. shape "     *** ****   "
  668. shape "   **     ****  "
  669. shape "   ****    **   "
  670. shape "  **  **  ***** "
  671. shape " **  **  **  ** "
  672. shape "** ***    ***** "
  673. shape "****      *  ** "
  674. shape "**         *****"
  675. shape "****************"
  676. shape " ***********    "
  677.  
  678. sperson:
  679. datab 1,12
  680. shape "                "
  681. shape "     ****       "
  682. shape "     ****       "
  683. shape "      **        "
  684. shape "    ****** *    "
  685. shape "   * **** *     "
  686. shape "     *****      "
  687. shape "    **  **      "
  688. shape "    **  **      "
  689. shape "    **  **      "
  690. shape "    **          "
  691. shape "                "
  692.  
  693. scar:
  694. datab 1,16
  695. shape "                "
  696. shape "                "
  697. shape "                "
  698. shape "***          ***"
  699. shape "*****  **  *****"
  700. shape "****************"
  701. shape "***  ******  ***"
  702. shape "    ***  ***    "
  703. shape "    ***  ***    "
  704. shape "***  ******  ***"
  705. shape "****************"
  706. shape "*****  **  *****"
  707. shape "***          ***"
  708. shape "                "
  709. shape "                "
  710. shape "                "
  711.  
  712. smirror:
  713. datab 1,9
  714. shape "                "
  715. shape "  *          *  "
  716. shape " **          ** "
  717. shape "****        ****"
  718. shape "****************"
  719. shape "****        ****"
  720. shape " **          ** "
  721. shape "  *          *  "
  722. shape "                "
  723.  
  724. null_thing:
  725. datab 1,22
  726. shape "                "
  727. shape "                "
  728. shape "                "
  729. shape "                "
  730. shape "                "
  731. shape "                "
  732. shape "                "
  733. shape "                "
  734. shape "                "
  735. shape "                "
  736. shape "                "
  737. shape "                "
  738. shape "                "
  739. shape "                "
  740. shape "                "
  741. shape "                "
  742. shape "                "
  743. shape "                "
  744. shape "                "
  745. shape "                "
  746. shape "                "
  747. shape "                "
  748.